package com.example.planetexploder.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;


import com.example.planetexploder.R;
import com.example.planetexploder.bean.otherdata.MenuItem;

import java.util.ArrayList;

public class MyAdapter_Menu extends BaseAdapter {

    private ArrayList<MenuItem> myList;
    private Context mContext;
    private TextView textListView;
    private CheckBox checkBookListView;

    public MyAdapter_Menu(Context mContext,
                          ArrayList<MenuItem> myList) {
        this.mContext = mContext;
        this.myList = myList;
    }

    @Override
    public int getCount() {
        return myList.size();
    }

    @Override
    public Object getItem(int position) {
        return myList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.listview_item, null);
        textListView = convertView.findViewById(R.id.text_Listview);
        checkBookListView = convertView.findViewById(R.id.check_Listview);
        checkBookListView.setChecked(myList.get(position).isChecked());
        textListView.setText(myList.get(position).getTitle());//设置显示内容
        return convertView;
    }
}
